﻿using System;
using CoreRay;
using System.Windows;
using CoreRay.Cameras;
using CoreRay.IO;

namespace CoreRay.Client
{
    class Program
    {
        [STAThread]
        private static void Main(string[] args)
        {
            ShowHeader();

            if (!CheckParameters(args))
            {
                ShowHelp();
                return;
            }

            SettingsWindow settings = new SettingsWindow();

            if (settings.ShowDialog() == false)
            {
                Environment.Exit(0);
            }

            using (Renderer renderer = new Renderer(settings.RenderSettings))
            {
                Scene scene = CoreRayContext.Current.ResourceManager.ReadResource<Scene>(settings.Settings.InputFilename);
                //Scene scene = CoreRayContext.Current.ResourceManager.ReadResource<Scene>("/Data/happy_buddha.dae");
                //Scene scene = CoreRayContext.Current.ResourceManager.ReadResource<Scene>("/Data/bunny.dae");
                //Scene scene = CoreRayContext.Current.ResourceManager.ReadResource<Scene>("/Data/sponza.dae");

                Application wpfApplication = new Application();
                wpfApplication.Run(new PreviewWindow(renderer, scene));
            }
        }

        private static bool CheckParameters(string[] args)
        {
            return true;
            if(args.Length == 4)
            {
                return true;
            }

            return false;
        }

        private static void ShowHeader()
        {
            Console.WriteLine("Core Ray Command Line Tool");
            Console.WriteLine("Version 0.1.1.1 .NET framework 3.5 ({0})", Environment.OSVersion);
            Console.WriteLine();
        }

        private static void ShowHelp()
        {
            Console.WriteLine("Usage: CoreRayCmd.exe -i [INPUT_FILE] -o [OUTPUT_FILE]");
        }
    }
}
